<template>
	<!-- 数据曲线 -->
	<view class="view">
		<view class="charts-box">
		  <qiun-data-charts
			:opts='opts'
		    type="tarea"
		    :chartData="chartData"
		    :errorShow="false"
		    background="none"
		  />
		</view>
	</view>
</template>
<script>
	import {tarea} from './config-ucharts.js'
	export default {
		data(){
			return{
				opts:tarea,
				chartData:{
					categories: [],
				    series: [
						{
							data: []
						}, 
					]
				},
			}
		},
		onShow() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: '#651D66'
			})
		},
		onShow() {
			this.def_db()
		},
		methods:{
			def_db(){
				this.$u.post('/appuser/health_curve').then(res=>{
					console.log(res.data);
					let { score,time} = res.data
					this.chartData.categories = time
					this.chartData.series[0].data = score
				})
			}
		}
	}
</script>
<style lang="scss">
	page{
		height: 100vh;
		background-image: linear-gradient(#651D66,#036219,#FB7C00);
	}
	.view{
		background-color: #FFFFFF;
		width: 95%;
		margin: 20rpx auto;
		padding: 20rpx;
		border-radius: 20rpx;
	}
	/* 请根据需求修改图表容器尺寸，如果父容器没有高度图表则会显示异常 */
	.charts-box{
	  width: 100%;
	  height:300px;
	}
</style>